package com.woniu.crowd.client;

import com.woniu.crowd.client.param.AddCrowdProductParam;
import com.woniu.crowd.client.param.ListCrowdParam;
import com.woniu.crowd.client.param.PartakeCrowdParam;
import com.woniu.crowd.client.param.upCrowdParam;
import com.woniu.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * name是项目名，contextId是client的名字
 */
@FeignClient(contextId = "crowdManageClient", name = "crowd")
public interface CrowdManageClient {
    /**
     * 新增众筹商品
     *
     * @param addCrowdProductParam
     * @return
     */
    @PostMapping("/addCrowdProduct")
    Result addCrowdProduct(@RequestBody AddCrowdProductParam addCrowdProductParam);

    /**
     * 用户参与众筹
     *
     * @param partakeCrowdParam
     * @return
     */
    @PostMapping("/userPartakeCrowd")
    Result userPartakeCrowd(@RequestBody PartakeCrowdParam partakeCrowdParam) throws Exception;


    /**
     * 众筹商品的文件上传
     *
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping(value = "/CrowdSpuUploadFile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result CrowdSpuUploadFile(@RequestPart(value = "file", required = false) MultipartFile file) throws IOException;

    /**
     * 众筹支付
     */
    @GetMapping("/crowdPay")
    void crowdPay(@RequestParam("crowdOrderNum") String crowdOrderNum) throws Exception;

    /**
     * 支付回调
     */
    @PostMapping("/crowdPayCallBack")
    void crowdPayCallBack();

    /**
     * 后台查询接口
     *
     * @param listCrowdParam
     * @return
     */
    @PostMapping("/manageListCrowd")
    Result manageListCrowd(@RequestBody ListCrowdParam listCrowdParam);

    /**
     * 上架众筹
     *
     * @param upCrowdParam
     * @return
     */
    @PostMapping("upCrowd")
    public Result upCrowd(@RequestBody upCrowdParam upCrowdParam);
}
